﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
        
            //引用所有驱动器
            DriveInfo[] driveInfos = DriveInfo.GetDrives();
            foreach (var d in driveInfos)
            {
                if (d.IsReady)
                {
                    Console.WriteLine(d.Name);
                    Console.WriteLine(d.DriveFormat);
                }
            }
            //在D盘根目录下创建一个叫：mySolo的文件夹（注意，创建前可能需要判断该文件夹是否存在）；
            bool falsh = Directory.Exists("D:\\mySolo");
            if (falsh)
            {
                Directory.Delete("D:\\mySolo",true);
                Directory.CreateDirectory("D:\\mySolo");

            }
            else
            {
                Directory.CreateDirectory("D:\\mySolo");
            }
            //输出D盘的文件名，驱动器类型，文件格式，可用空间，总空间
            DriveInfo driveInfo = new DriveInfo("D");
            Console.WriteLine(driveInfo.Name);
            Console.WriteLine(driveInfo.DriveType);
            Console.WriteLine(driveInfo.DriveFormat);
            Console.WriteLine(driveInfo.AvailableFreeSpace);
            Console.WriteLine(driveInfo.RootDirectory);
            //在上一步创建的目录中，创建一个叫test.txt的文件；
          
          
            FileStream fileStream = new FileStream("D:\\mySolo\\test.txt",FileMode.OpenOrCreate,FileAccess.ReadWrite);
            StreamWriter streamWriter = new StreamWriter(fileStream);
            streamWriter.WriteLine("海浪打湿白裙试图推你退去，岸上的人民脸上挂着无关");
            streamWriter.WriteLine("哈哈");
            streamWriter.Close();

        }
    }
}
